<template>
  <el-table
    :data="tableData"
    border
    style="width: 60%;margin-left: 20%">
    <el-table-column
      fixed
      prop="id"
      label="id"
      width="180">
    </el-table-column>
    <el-table-column
      prop="title"
      label="课程名字"
      width="180">
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      width="200">
      <template slot-scope="scope">
        <el-button @click="handleClick(scope.row)" type="text" size="small">查看学生</el-button>
        <el-button type="text" size="small">查看课程信息</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
    import Api from '../common/api'
    export default {
        name: "check-student",
        methods:{
          handleClick(row) {
            console.log(row);
          }
        },
      created(){
        let user=Api.getStorageItem("user");
        this.user=user;
        Api.apiCall('get','/course/get_by_teacher_id/'+this.user.id).then((resolve)=>{
          console.log(resolve,'加载的数据')
          this.tableData=resolve.data.data.courses;
        },(reject)=>{
          this.$message.error("加载数据错误，请检查网络")
        })
      },
      data(){
          return{
            user:'',
            tableData: [
              {
              id: '0157843655',
              title: '王小虎'
            }]
        }
      }
    }
</script>

<style scoped>

</style>
